package com.wlld.yolo;

import com.wlld.MatrixTools.Matrix;
import com.wlld.i.OutBack;

/**
 * @param
 * @DATA
 * @Author LiDaPeng
 * @Description
 */
public class FoodBack implements OutBack {
    private int id;
    private double point = -2;
    private int[] valueId;
    private double[] value = new double[5];
    private boolean isValue = false;

    public double[] getValue() {
        return value;
    }

    public void setValueId(int[] valueId) {
        this.valueId = valueId;
        isValue = true;
    }

    public void clear() {
        id = 0;
        point = -2;
    }

    public int getId() {
        return id;
    }

    public double getPoint() {
        return point;
    }

    private int isHere(int id) {
        int index = -1;
        if (isValue) {
            for (int i = 0; i < valueId.length; i++) {
                if (valueId[i] == id) {
                    index = i;
                    break;
                }
            }
        }
        return index;
    }

    @Override
    public void getBack(double out, int id, long eventId) {
        int index = isHere(id);
        if (index == -1) {
            if (out > point) {
                point = out;
                this.id = id;
            }
        } else {
            value[index] = out;
        }
    }

    @Override
    public void getBackMatrix(Matrix matrix, long eventId) {

    }
}
